package com.wuyou.designPatterns.prototype.framework;

import java.util.HashMap;
import java.util.Map;

public class Manager {

    private Map<String, Product> showcase = new HashMap<>();

    public void register(String name, Product proto){
        showcase.put(name, proto);
    }

    public Product create(String protoname){
        Product product = showcase.get(protoname);
        if (product == null) {
            throw new IllegalArgumentException("请先注册模板");
        }
        return product.createClone();
    }

}
